import Book.BookList;
import Person.Administrator;
import Person.Ordinary;
import Person.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-02-16
 * Time: 01:42
 */
public class Main {

    public static User login(){
        Scanner in = new Scanner(System.in);
        System.out.println("请输入你的姓名");
        String name = in.nextLine();
        System.out.println("请选择你的身份    1.管理员    2.普通用户");
        int identity = in.nextInt();
        if (identity == 1){
            return new Administrator(name);
        }else {
            return new Ordinary(name);
        }
    }

    public static void main(String[] args) {
        BookList bookList = new BookList();
        User user = login();//利用login方法的返回值完成了向上转型
        while (true){
            int choice = user.menu();
            user.setFunc(choice,bookList);

        }
    }
}